<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="utf-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>考试管理</title>
    <link href="<%=path%>/CSS/style.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="<%=path%>/JQuery/jquery-1.8.2.js"></script>
    <%@ include file="/WEB-INF/JSP/ajax.jsp" %>
    <script type="text/javascript" src="<%=path%>/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript">


    </script>
    <style type="text/css">
        .scbtn2 {
            height: 20px;
            background: #57a0ff;
            border-radius: 20px;
            width: 50px;
            color: #fff;
            display: none;
        }

        .seachform li label {
            line-height: 45px;
            color: #444444
        }

        .scinput {
            line-height: 10px;
            margin-top: 5px
        }

        .scinput1 {
            margin-top: 5px;
            height: 30px;
        }

        .scbtn {
            background: #57a0ff;
            border-radius: 20px;
            width: 110px;
            margin-top: 4px;
            height: 35px
        }

        .scbtn2 {
            height: 20px;
            background: #57a0ff;
            border-radius: 20px;
            width: 50px;
            color: #fff;
            display: none;
        }

        .tablelist {
            border: none;
            margin: 10px 20px
        }

        .tablelist th {
            background: none;
            border-bottom: none;
        }

        thead {
            background: #f2f2f2
        }

        /*tbody tr:nth-child(even) {
            background: #f7f8fd
        }*/

        .tablelist th {
            height: 45px;
        }

        .tablelist td {
            border-right: none;
        }

        tbody tr {
            height: 38px
        }

        .check {
            padding-left: 0px
        }

        a {
            cursor: pointer;
        }

        #student td {
            width: 100%;
            padding-left: 30px;
            text-align: center;
        }

        .head th {
            text-align: center;
        }

        #cent td {
            text-align: center;
            padding-left: 5px;
        }

        table tr td {
            font-size: 12px
        }


        table tr th {
            font-size: 14px
        }

        .heads span {
            width: 1573px;
            float: left;
            height: 45px;
            text-align: center;
            line-height: 45px;
            background: #eee;
            font-weight: bold;
            font-size: 14px;
        }
        .tablelist tr td{border-bottom:1px solid #BBB;}
        tbody tr:nth-child(even) {background: #f7f8fd}
    </style>
</head>
<body style="background: #f5f5f5;padding: 0 10px;">
<div id="location_top">
<div class="place" style="background: #f5f5f5;margin-top: 10px">
    <ul class="placeul">
        <li><a href="#">考试管理</a></li>
        <li><a href="<%=path%>/DrivingSys/querySubjectThreeNo/look.action">科目三编号</a></li>
    </ul>
</div>

<div class="rightinfo" style="background: #fff;border-radius:10px;height: 45px;">

    <form action="<%=path%>/DrivingSys/querySubjectThreeNo/look.action" method="post" onsubmit="selState()">
        <ul class="seachform">
            <ul class="seachform">
                <li><label>序号</label><input name="fnumber" type="text" class="scinput" value="${fnumber}"/></li>
                <%-- <li><label>参考消息</label><input name="fdescription" type="text" class="scinput" value="${fdescription}"/>
                </li> --%>
                <li><label>学员</label><input name="cfstudentname" type="text" class="scinput" value="${cfstudentname}"/>
                </li>
                <li><label>约考开始时间</label><input class="scinput1" name="beginTime" type="text"
                                                onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}',dateFmt:'yyyy-MM-dd'})"
                                                id="datemin" class="input-text Wdate" style="width:150px;"
                                                value="${beginTime}"></li>
                <li><label>约考结束时间</label><input class="scinput1" name="endTime" type="text"
                                                onfocus="WdatePicker({minDate:'#F{$dp.$D(\'datemin\')}',dateFmt:'yyyy-MM-dd'})"
                                                id="datemax" class="input-text Wdate" style="width:150px;"
                                                value="${endTime}"></li>
                <li><label>&nbsp;</label><input name="" type="submit" style="outline: none;" class="scbtn"
                                                value="立即查询"/><input type="hidden" name="selectState" value="-1"/></li>
            </ul>
        </ul>
    </form>
</div>
</div>
<div id="data_table_new"
     style="margin-bottom: 0px;margin-top: 30px;background: #fff;border-radius:10px;box-shadow: 0 0 10px #f2f2f2;">
    <ul>
        <li style="height: 40px;text-align: left;color: #999999;">
                   <span style="font-size: 12px;">
                <shiro:hasPermission name="/intoAddSubjectThreeNo">
				   <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                        src="<%=path%>/images/list/xz.png">
                    &nbsp;<a onclick="gotoSelectCard(this)" funurl="<%=path%>/DrivingSys/intoAddSubjectThreeNo">新增</a>
                </shiro:hasPermission>
                <shiro:hasPermission name="/deleteSubjectThreeNoByFid">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                       src="<%=path%>/images/list/sc.png">
                    &nbsp;<a class="del">删除</a>
                </shiro:hasPermission>
                <shiro:hasPermission name="/intoUpdateSubjectThreeNo">
                    <img alt="" height="11px" src="<%=path%>/images/list/xg.png" style="padding-left: 20px">
                    <a style="color: #000" class="modify">修改</a>
                </shiro:hasPermission>
                <shiro:hasPermission name="/uploadSubjectThreeNoMass">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                       src="<%=path%>/images/list/xz.png">
                    &nbsp;<a href="#" id="uploadEventBtn" >导入数据</a>
                </shiro:hasPermission>
                <shiro:hasPermission name="/exportSubjectThreeNoMassExcle">
				  <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                       src="<%=path%>/images/list/xz.png">
                    &nbsp;<a href="<%=path%>/DrivingSys/exportSubjectThreeNoMassExcle" >引出模板</a>
                </shiro:hasPermission>
                       <shiro:hasPermission name="/importExcelSubjectThreeNo">
                          <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;width: 14px" src="<%=path%>/images/list/excel.png">
                          &nbsp;<a class="importExcel">导出Excle</a>
                   </shiro:hasPermission>
                    <form id="batchUpload"  action="" method="post" class="form-horizontal" enctype="multipart/form-data" style="margin-left: 22px;display: inline-block">
                        <!-- <button class="btn btn-success btn-xs" id="uploadEventBtn" style="height:26px;"  type="button" >选择文件</button> -->
                        <input type="file" name="file"  style="width:0px;height:0px;" id="uploadEventFile">
                        <input type="hidden" id="uploadEventPath"  disabled="disabled"  placeholder="请选择excel表" style="border: 1px solid #e6e6e6; height: 26px;width: 200px;" >
                    </form>
				  </span>
        </li>
    </ul>
    <%--<form id="batchUpload"  action="" method="post" class="form-horizontal" enctype="multipart/form-data" >
    	<!-- <button class="btn btn-success btn-xs" id="uploadEventBtn" style="height:26px;"  type="button" >选择文件</button> -->
    	<input type="file" name="file"  style="width:0px;height:0px;" id="uploadEventFile">  
    	<input type="hidden" id="uploadEventPath"  disabled="disabled"  placeholder="请选择excel表" style="border: 1px solid #e6e6e6; height: 26px;width: 200px;" >                                           
	</form>--%>
    <table class="tablelist" style="white-space:nowrap;">
        <thead>
        <tr class="sq">
            <th><input type="checkbox"  class="check"  /></th>
            <th>学员</th>
            <th>序号</th>
            <th>证件号码</th>
            <th>准考证编号</th> 
            <th>流水号</th>  
            <th>约考日期</th> 
            <th>考试地点</th>  
            <th>驾校简称</th>
            <th>考试科目</th>
            <th>约考顺序</th> 
            <th>考试车型</th>
            <th>考试场次</th>
            <th>准考车型</th>    
            <th style="text-align:center;">操作</th>
        </tr>
        </thead>
        <c:if test="${empty subjectThreeNoList  }">
        	<tr class="sq">
        		<th colspan="13">
        			<span >抱歉,没有任何相关的记录信息!</span>
        		</th>
        	</tr>
        </c:if>
        <c:forEach items="${subjectThreeNoList}" var="subjectThreeNo" varStatus="s">
            <tr>
            	<td><input type="checkbox"   name="check" value="${subjectThreeNo.fid}"/></td>
            	<td>${subjectThreeNo.studentName }</td>
              	<td>${subjectThreeNo.cfxh }</td>
              	<td>${subjectThreeNo.cfzjhm }</td>
              	<td>${subjectThreeNo.cfzkzmbh }</td>
              	<td>${subjectThreeNo.cflsh }</td>
              	<td>${subjectThreeNo.cfykrq }</td>
              	<td>${subjectThreeNo.cfksdd }</td>
              	<td>${subjectThreeNo.cfjxjc }</td>
              	<td>${subjectThreeNo.cfkskm }</td>
              	<td>${subjectThreeNo.cfyksx }</td>
               	<td></td> 
              	<td>${subjectThreeNo.cfkscc }</td>
              	<td>${subjectThreeNo.cfzkcx }</td>
              	<td>
                    <shiro:hasPermission name="/intoUpdateSubjectThreeNo">
                        <img alt="" height="11px" src="<%=path%>/images/list/xg.png">
                        <a href="<%=path%>/DrivingSys/intoUpdateSubjectThreeNo?fid=${subjectThreeNo.fid}"
                           class="tablelink">修改</a>&nbsp;&nbsp;&nbsp;
                    </shiro:hasPermission>
                    <shiro:hasPermission name="/deleteSubjectThreeNoByFid">
                        <img alt="" style="margin-top: 20px;margin-left: 22px;height: 12px;"
                             src="<%=path%>/images/list/sc.png">
                        &nbsp;<a class="delOne" class="tablelink" style="color: #056dae">删除<input type="hidden" value="${subjectThreeNo.fid}"></a>
                        &nbsp;&nbsp;&nbsp;
                    </shiro:hasPermission>
                </td>
            </tr>        
        </c:forEach>
        <%--信息总数--%>
        <tr class="sq">
            <td>合计:</td>
            <td>${messageAmount}</td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
</div>
<div id="location_bottom">
 <pg:pager items="${pb.tr}" url="${pb.url}" export="offset,currentPageNumber=pageNumber" maxPageItems="${pb.ps}">
     <pg:param name="fnumber" value="${fnumber}"/>
     <pg:param name="cfstudentname" value="${cfstudentname}"/>
     <pg:param name="beginTime" value="${beginTime}"/>
     <pg:param name="endTime" value="${endTime}"/>
     <pg:param name="selectState" value="${selectState}"/>
            <pg:index>  
               <pg:first>
               <a href="${pageUrl}&&type=${type}" >
               <nobr>
               [首页]
               </nobr>
              </a>   
               </pg:first>  
               <pg:prev><a href="${pageUrl}&&type=${type}">前一页</a></pg:prev>  
               <pg:pages>  
                     <c:choose>  
                        <c:when test="${currentPageNumber eq pageNumber}">    
                           <font color="red">${pageNumber }</font>  
                        </c:when>    
                        <c:otherwise>    
                           <a href="${pageUrl}&&type=${type}">${pageNumber}</a>   
                        </c:otherwise>    
                     </c:choose>  
               </pg:pages>  
               <pg:next><a href="${pageUrl}&&type=${type}">下一页</a></pg:next>  
               <pg:last><a href="${pageUrl}&&type=${type}"><nobr>[尾页]</nobr></a></pg:last>  
            </pg:index>      
         </pg:pager>
</div>
     <div class="tip">
    <div class="tiptop">
        <span>提示信息</span>
    </div>
    <div class="tipinfo">
        <span><img src="<%=path%>/images/ticon.png"/></span>
        <div class="tipright">
            <p>是否确认对信息删除 ？</p>
            <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
        </div>
    </div>
    <div class="tipbtn">
        <input name="" type="button" class="sure" value="确定"/>&nbsp; <input
            name="" type="button" class="cancel" value="取消"/>
    </div>
</div>
</body>
<script type="text/javascript" src="<%=path%>/JS/tempJs/tool.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var type = "${type}";
        if (type == '0' || type == '' || type == null) {

        } else {
            //alert("添加成功");
            editAlert();
        }
        fixation_List();
    })

    $(document).ready(function () {
        //删除多个
        $('.del').click(function () {
            /* $('.check').toggle() */
            /* $('.scbtn2').toggle() */
            var fidids = document.getElementsByName("check");
            var carid;
            for (var i = 0; i < fidids.length; i++) {
                if (fidids[i].checked) {
                    carid = fidids[i].value;
                }
            }
            if (carid == null || carid == "") {
                alert("请至少选择一条数据删除")
                return false
            } else {
                $(".tip").fadeIn(200);
            }
            $(".sure").click(function () {
                $(".tip").fadeOut(100);
                // $('.check').toggle()
                //$('.scbtn2').toggle()
                /* location='deleteCarByFid?deleteId='+deleteId+''; */
                var str = new Array();
                var fids = document.getElementsByName("check");
                for (var i = 0; i < fids.length; i++) {
                    if (fids[i].checked) {
                        str[i] = fids[i].value;
                    }
                }
                location = '<%=path%>/DrivingSys/deleteSubjectThreeNoByFid?deleteId=' + str + '';
            })

            $(".cancel").click(function () {
                $(".tip").fadeOut(100);
            });
        })
        //删除单个
        $('.delOne').click(function () {
            var fid = $(this).find("input:hidden").val();
            $('.window-mask').fadeToggle()
            $(".tip").fadeIn(200);
            $(".sure").click(function () {
                location = '<%=path%>/DrivingSys/deleteSubjectThreeNoByFid?fid=' + fid + '';
            })

            $(".cancel").click(function () {
                $(".tip").fadeOut(100);
            });
        })

        //修改
        $(".modify").click(function () {
            var stringFid;
            var fids = document.getElementsByName("check");
            var	schools
            for (var i = 0; i < fids.length; i++) {
                if (fids[i].checked) {
                    stringFid = fids[i].value;
                    location = '<%=path%>/DrivingSys/intoUpdateSubjectThreeNo?fid=' + stringFid + '';
                    return false
                }
            }
            if (stringFid == null || stringFid.length == 0) {
                alert("请至少选择一条数据修改")
                return false
            }
        })
        //查询详情
        $(".tablelist tr:not(.sq)").dblclick(function () {
            var modify = $(".modify").text();
            if(modify == '' || modify == null){

            }else{
                var fid2 = $(this).find("input:checkbox[name=check]").val();
                //避免fid中有+，或者特殊字符
                var fid = encodeURI(fid2).replace(/\+/g, '%2B')
                gotoSelectCard(this,'/DrivingSys/intoUpdateSubjectThreeNo?fid='+fid);

                //location = '<%=path%>/DrivingSys/intoUpdateSubjectThreeNo?fid=' + fid + '';
            }

        })
        //全选全不选
		$(".check").click(function(){
			if(this.checked){
			    $("[name=check]").attr("checked",true);}
			else{ $("[name=check]").attr("checked",false);}
		})
    })
    
    var User = function(){  
    
    this.init = function(){  
          
        //上传excel  
         $("#uploadEventBtn").unbind("click").bind("click",function(){  
             $("#uploadEventFile").click();  
         });  
         $("#uploadEventFile").bind("change",function(){  
             $("#uploadEventPath").attr("value",$("#uploadEventFile").val());  
             var uploadEventFile = $("#uploadEventFile").val();
             var uploadEventFile = $("#uploadEventFile").val();
             var pos=uploadEventFile.lastIndexOf("\\");
             $.messager.confirm('提示', '是否把'+uploadEventFile.substring(pos+1)+'导入科目三编号!', function (r) {
                 if(r) {//弹出确认对话框
                     if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel
                         alert("只能上传Excel文件");
                         return false;
                     }else{
                         var url =  '<%=path%>/DrivingSys/uploadSubjectThreeNoMass';
                         var formData = new FormData($('form')[1]);
                         //alert(formData)
                         user.sendAjaxRequest(url,'POST',formData);
                     }
                     var file = document.getElementById('uploadEventFile');
                     file.value = ''; //虽然file的value不能设为有字符的值，但是可以设置为空值
                     return true;    //点击确定时，返回值为true，执行如上操作。
                 }else{
                     var file = document.getElementById('uploadEventFile');
                     file.value = ''; //虽然file的value不能设为有字符的值，但是可以设置为空值
                     return false; //点击取消时，返回值为false，不执行操作。
                 }
             })
         });  
          
    };  
   <%--  //点击上传按钮  
    this.uploadBtn = function(){  
        var uploadEventFile = $("#uploadEventFile").val();  
        if(uploadEventFile == ''){  
            alert("请选择excel,再上传");  
        }else if(uploadEventFile.lastIndexOf(".xls")<0){//可判断以.xls和.xlsx结尾的excel  
            alert("只能上传Excel文件");  
        }else{  
            var url =  '<%=path%>/DrivingSys/upload';  
            var formData = new FormData($('form')[0]);
            //alert(formData)
            user.sendAjaxRequest(url,'POST',formData);  
        }  
    };   --%>
      
    this.sendAjaxRequest = function(url,type,data){  
        $.ajax({  
            url : url,  
            type : type,  
            data : data,  
            success : function(result) { 
            	if(result == null){
            		alert("没有可以导入的数据！")
            	}else{
            		var str="";
                	for (var i = 0; i <result["error"].length; i++) {
    					str+="姓名:"+result["error"][i].stuName+"    失败原因:未找到该学员信息\n\n";
    				}
                	var successNum=Number(result["success"].length);
                	var errorNum=Number(result["error"].length);
                    alert("总共有"+(successNum+errorNum)+"条数据，"+
                    		"其中失败"+result["error"].length+"条\n\n"+str);  
            	}              
            },  
            error : function() {  
                alert( "excel上传失败");  
            },  
            cache : false,  
            contentType : false,  
            processData : false  
        });  
    };  
}  
      
  
var user;  
$(function(){  
    user = new User();  
    user.init();  
});
    $('.btn').click(function () {
        location='<%=path%>/DrivingSys/querySubjectThreeNo/look.action';
    })

    //用于业务日期全部输入给空时查询全部内容 做一个标记给后台
    function  selState() {
        var beginTime =$("input:text[name=beginTime]").val();
        var endTime =$("input:text[name=endTime]").val();
        if(beginTime == "" || endTime == ""){
            $("input:hidden[name=selectState]").val("1");
        }
    }



    //导出
    $('.importExcel').live('click',function () {
        var cfxh = $("input[name='fnumber']").val();//序号
        var cfstudentname = $("input[name='cfstudentname']").val();//学生姓名
        var beginTime = $("input[name='beginTime']").val();//学生姓名
        var endTime = $("input[name='endTime']").val();//学生姓名
        location = '<%=path%>/DrivingSys/importSubjectThreeNo?cfxh='+cfxh+"&cfStudentName="+cfstudentname+"&beginTime="+beginTime+"&endTime="+endTime
    })
</script>
</html>
